package andriod.action.personalOffice;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Date;
import java.util.List;

import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;

import com.jcrj.action.BaseAction;
import com.jcrj.entity.OUser;
import com.jcrj.entity.OWorkLan;
import com.jcrj.service.PersonalofficeService;
import com.jcrj.util.DateProcessor;

public class LanguageSetAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = -2873602308010396201L;
	private PersonalofficeService personalofficeService;

	public PersonalofficeService getPersonalofficeService() {
		return personalofficeService;
	}

	public void setPersonalofficeService(
			PersonalofficeService personalofficeService) {
		this.personalofficeService = personalofficeService;
	}

	public String getWorkLanAll() {
		OUser user = (OUser) super.getSession().get("userInfo");
		List<OWorkLan> workLanList = this.personalofficeService
				.getWorkLanList(user.getId().intValue());
		JsonConfig config = new JsonConfig();
		config.setExcludes(new String[]{"id","userId"});
		DateProcessor dateProcessor = new DateProcessor();
		config.registerJsonValueProcessor(Date.class, dateProcessor);
		config.registerJsonValueProcessor(java.util.Date.class, dateProcessor);
		JSONArray array = JSONArray.fromObject(workLanList,config);
		getResponse().setContentType("json/text;charset=utf-8");
		try {
			PrintWriter out = getResponse().getWriter();
			out.print(array.toString());
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}